]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellGlobal: use MetaCursorTracker to query the pointer position
authorGiovanni Campagna <gcampagn@redhat.com>
Wed, 14 Aug 2013 14:59:39 +0000 (16:59 +0200)
committerGiovanni Campagna <gcampagn@redhat.com>
Thu, 12 Sep 2013 08:34:25 +0000 (10:34 +0200)
Gdk uses Xwayland, so it only sees the events we forward to X11
clients. Instead, we can use the abstraction API provided by
mutter and get the right value automatically.
Also, we need to use MetaCursorTracker to handle the cursor
visibility too.

https://bugzilla.gnome.org/show_bug.cgi?id=707467

js/ui/magnifier.js
js/ui/screenShield.js
src/shell-global.c

index 50ddd72405a963891fce5eaef054657c6f6f64e5..cccddaa8f10f73dcfec131ec721b5c86ef796fca 100644 (file)
@@ -88,7 +88,7 @@ const Magnifier = new Lang.Class({
      * Show the system mouse pointer.
      */
     showSystemCursor: function() {
-        global.stage.show_cursor();
+        this._cursorTracker.set_pointer_visible(true);
     },
 
     /**
@@ -96,7 +96,7 @@ const Magnifier = new Lang.Class({
      * Hide the system mouse pointer.
      */
     hideSystemCursor: function() {
-        global.stage.hide_cursor();
+        this._cursorTracker.set_pointer_visible(false);
     },
 
     /**
@@ -117,7 +117,7 @@ const Magnifier = new Lang.Class({
         // Make sure system mouse pointer is shown when all zoom regions are
         // invisible.
         if (!activate)
-            global.stage.show_cursor();
+            this._cursorTracker.set_pointer_visible(true);
 
         // Notify interested parties of this change
         this.emit('active-changed', activate);
index cad5832ed5d8e6cd8faa5341c411036fa312a9ab..e5ba2de302260d29431e9c2b8ae0f837c720e009 100644 (file)
@@ -584,6 +584,7 @@ const ScreenShield = new Lang.Class({
         this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown));
 
         this.idleMonitor = Meta.IdleMonitor.get_core();
+        this._cursorTracker = Meta.CursorTracker.get_for_screen(global.screen);
     },
 
     _createBackground: function(monitorIndex) {
@@ -953,7 +954,7 @@ const ScreenShield = new Lang.Class({
             this._hideLockScreenComplete();
         }
 
-        global.stage.show_cursor();
+        this._cursorTracker.set_pointer_visible(true);
     },
 
     _ensureUnlockDialog: function(onPrimary, allowCancel) {
@@ -1094,7 +1095,7 @@ const ScreenShield = new Lang.Class({
 
             return false;
         });
-        global.stage.hide_cursor();
+        this._cursorTracker.set_pointer_tracker(false);
 
         this._lockScreenState = MessageTray.State.SHOWN;
         this._lockScreenGroup.fixed_position_set = false;
index 3f85ac5013d095f61e775590298069e08da44919..8a753b14aaa8837d4ab9f6a177a0cbc422a47d5d 100644 (file)
@@ -1243,9 +1243,6 @@ void shell_global_init_xdnd (ShellGlobal *global)
  * @mods: (out): the current set of modifier keys that are pressed down
  *
  * Gets the pointer coordinates and current modifier key state.
- * This is a wrapper around gdk_display_get_pointer() that strips
- * out any un-declared modifier flags, to make gjs happy; see
- * https://bugzilla.gnome.org/show_bug.cgi?id=597292.
  */
 void
 shell_global_get_pointer (ShellGlobal         *global,
@@ -1253,18 +1250,13 @@ shell_global_get_pointer (ShellGlobal         *global,
                           int                 *y,
                           ClutterModifierType *mods)
 {
-  GdkDeviceManager *gmanager;
-  GdkDevice *gdevice;
-  GdkScreen *gscreen;
-  GdkModifierType raw_mods;
-
-  gmanager = gdk_display_get_device_manager (global->gdk_display);
-  gdevice = gdk_device_manager_get_client_pointer (gmanager);
-  gdk_device_get_position (gdevice, &gscreen, x, y);
-  gdk_device_get_state (gdevice,
-                        gdk_screen_get_root_window (gscreen),
-                        NULL, &raw_mods);
-  *mods = raw_mods & GDK_MODIFIER_MASK;
+  ClutterModifierType raw_mods;
+  MetaCursorTracker *tracker;
+
+  tracker = meta_cursor_tracker_get_for_screen (global->meta_screen);
+  meta_cursor_tracker_get_pointer (tracker, x, y, &raw_mods);
+
+  *mods = raw_mods & CLUTTER_MODIFIER_MASK;
 }
 
 /**
@@ -1279,19 +1271,10 @@ void
 shell_global_sync_pointer (ShellGlobal *global)
 {
   int x, y;
-  GdkModifierType mods;
-  GdkDeviceManager *gmanager;
-  GdkDevice *gdevice;
-  GdkScreen *gscreen;
+  ClutterModifierType mods;
   ClutterMotionEvent event;
 
-  gmanager = gdk_display_get_device_manager (global->gdk_display);
-  gdevice = gdk_device_manager_get_client_pointer (gmanager);
-
-  gdk_device_get_position (gdevice, &gscreen, &x, &y);
-  gdk_device_get_state (gdevice,
-                        gdk_screen_get_root_window (gscreen),
-                        NULL, &mods);
+  shell_global_get_pointer (global, &x, &y, &mods);
 
   event.type = CLUTTER_MOTION;
   event.time = shell_global_get_current_time (global);